LC2=K_store(:,2)+a_vec(2)*S_store;
LC3=K_store(:,3)+a_vec(3)*S_store;

K1=reshape(K_store(:,1),[length(delta_grid),length(eta_grid)]);
K2=reshape(K_store(:,2),[length(delta_grid),length(eta_grid)]);
K3=reshape(K_store(:,3),[length(delta_grid),length(eta_grid)]);

S=reshape(S_store,[length(delta_grid),length(eta_grid)]);

figure(1)
mesh(K1)

figure(2)
mesh(K2)

figure(3)
mesh(K3)

figure(4)
mesh(S)

figure(5)
theta_opt=theta_mat(LC2==chi2inv(.95,1),:);
S_opt=S_store(LC2==chi2inv(.95,1),:);
S_trim=max(S,S_opt-2);
S_trim=min(S_trim,S_opt+2);
mesh(S_trim)

